package com.qing.springbootinit.bizmq;

import com.rabbitmq.client.Channel;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;



@Component
@Slf4j
public class MyMessageConsumer {

        @SneakyThrows
        @RabbitListener(queues = {"code_queue"},ackMode = "MANUAL")
        public void receiveMessage (String message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliverTag){

                log.info("message = {}",message);
//                手动确认消费信息
                channel.basicAck(deliverTag,false);

        }


}
